// AudioOutDS.h: interface for the AudioOutDS class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_AUDIOOUTDS_H__13585082_4291_40B9_962A_6EFF026739E0__INCLUDED_)
#define AFX_AUDIOOUTDS_H__13585082_4291_40B9_962A_6EFF026739E0__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define WIN32_LEAN_AND_MEAN
#include <atlbase.h>
#include <qedit.h>
#include <dshow.h>
#include <windows.h>
class CNullSource;
#ifndef MYFREEMEDIATYPE
#define MYFREEMEDIATYPE(mt)	{if ((mt).cbFormat != 0)\
					{CoTaskMemFree((PVOID)(mt).pbFormat);\
					(mt).cbFormat = 0;\
					(mt).pbFormat = NULL;\
				}\
				if ((mt).pUnk != NULL)\
				{\
				(mt).pUnk->Release();\
				(mt).pUnk = NULL;\
				}}									
#endif

class CAudioOutGrabber  
{
private:

	BOOL m_bConnected;

	CComPtr<IGraphBuilder> m_pGraph;
	CComPtr<IMediaControl> m_pMediaControl;
	CComPtr<IMediaEvent> m_pMediaEvent;
	CComPtr<IBaseFilter> m_pNullSource;
	//CComPtr<IBaseFilter> m_pDeviceFilter;
	CNullSource * m_pNullSourceClass;
	//CComPtr<IPin> m_pDeviceInput;
	CComPtr<IPin> m_pNullSourcePin;
	HRESULT AddToRot(IUnknown *pUnKnown,DWORD * pdwRegister);
	void RemoveFromRot(DWORD pdwRegister);
	DWORD m_dwRegister;

	bool BindFilter( IBaseFilter **pFilter);
public:
	CAudioOutGrabber();
	virtual ~CAudioOutGrabber();
	BOOL OpenRender();
	BOOL CloseRender();
	BOOL PushBuffer(BYTE * pBuffer,long nSize);

};

#endif // !defined(AFX_AUDIOOUTDS_H__13585082_4291_40B9_962A_6EFF026739E0__INCLUDED_)
